<?php

use think\migration\Migrator;
use think\migration\db\Column;

class CreateShopDataFakeUserTable extends Migrator
{
    /**
     * Migrate Up.
     */
    public function up()
    {
        $table = $this->table('shop_data_fake_user', ['comment' => '虚拟用户', 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci']);
        $table->addColumn('username', 'string', ['limit'  =>  60, 'null' => true, 'default' => null, 'comment' => '用户名'])
            ->addColumn('nickname', 'string', ['limit'  =>  60, 'null' => true, 'default' => null, 'comment' => '昵称'])
            ->addColumn('mobile', 'string', ['limit'  =>  20, 'null' => true, 'default' => null, 'comment' => '手机号'])
            ->addColumn('password', 'string', ['limit'  =>  60, 'default' => '', 'comment' => '密码'])
            ->addColumn('avatar', 'string', ['limit'  =>  255,'null' => true, 'default' => null, 'comment' => '头像'])
            ->addColumn(Column::tinyInteger('gender')->setDefault(0)->setUnsigned()->setComment('性别'))
            ->addColumn('email', 'string', ['limit'  =>  60, 'null' => true, 'default' => null, 'comment' => '邮箱'])
            ->addColumn('create_time', 'integer', ['limit'  =>  10, 'null' => true, 'default' => null, 'comment' => '创建时间'])
            ->addColumn('update_time', 'integer', ['limit'  => 10, 'null' => true, 'default' => null, 'comment' => '更新时间'])
            ->create();
    }

    /**
     * Migrate Down.
     */
    public function down()
    {
        $table = $this->table('shop_data_fake_user');
        $table->drop();
    }
}
